package com.heima.admin.job;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.ListUtil;
import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.feigns.wemedia.WemediaFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by ZYJ on 2021/6/2 19:31
 * 自媒体文章定时审核发布任务
 */
@Component
@Slf4j
public class WemediaNewsAutoScanJob {
    @Autowired
    WemediaNewsAutoScanService wemediaNewsAutoScanService;
    @Autowired
    private WemediaFeign wemediaFeign;
    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> autoScanJob(String params) {
        log.info("==================文章自动审核任务======================");
        List<Integer> releaseIdList = wemediaFeign.findRelease();
        if(CollUtil.isNotEmpty(releaseIdList)){
            releaseIdList.forEach(wemediaNewsAutoScanService::autoScanByMediaNewsId);
        }
        return ReturnT.SUCCESS;
    }
}
